//
//  MainViewController.m
//  智慧小区
//
//  Created by 高永杨 on 2017/3/16.
//  Copyright © 2017年 zhongchuang. All rights reserved.
//

#import "MainViewController.h"
#import "HeadViewController.h"
#import "MyViewController.h"
#import <AFNetworking.h>
@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
   
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    attrs[NSForegroundColorAttributeName] = [UIColor colorWithHexString:@"666666"];
    NSMutableDictionary *selectAttrs = [NSMutableDictionary dictionary];
    selectAttrs[NSFontAttributeName] = attrs[NSFontAttributeName];
    selectAttrs[NSForegroundColorAttributeName]  = [UIColor colorWithHexString:@"666666"];
    UIBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectAttrs forState:UIControlStateSelected];
    self.tabBar.barTintColor = [UIColor whiteColor];
    //添加子控制器
    [self setupchildVc:[[HeadViewController alloc]init] imag:@"shouye_icon_greey" selectImage:@"shouye_icon_bule" title:@"首页"];
    [self setupchildVc:[[MyViewController alloc]init] imag:@"my_icon_greey" selectImage:@"my_icon_bule.png" title:@"我的"];
    // Do any additional setup after loading the view from its nib.

   
    //自定义标题视图
    UIFont *font = [UIFont systemFontOfSize:17.f];
    NSDictionary *textAttributes = @{
                                     NSFontAttributeName : font,
                                     NSForegroundColorAttributeName : [UIColor whiteColor]
                                     };
    [[UINavigationBar appearance] setTitleTextAttributes:textAttributes];
}


-(void)setupchildVc:(UIViewController *)vc  imag:(NSString *)image selectImage:(NSString*)selecimge title:(NSString *)title
{
    
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:image];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selecimge];
    [self addChildViewController:nav];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
